package aeolus.wind.spider.web.commons.spider;

import java.util.HashSet;
import java.util.Set;

public class MaxInGroup {

    private String      abilityName;
    private Set<String> nameList;
    private Double      value;

    public MaxInGroup(String abilityName) {
        this.abilityName = abilityName;
        this.nameList = new HashSet<String>();
        this.value = Double.valueOf(0);
    }

    public void update(String identityName, Double value) {
        if (this.value == null || value > this.value) {
            this.value = value;
            this.nameList.clear();
            this.nameList.add(identityName);
        }
        if (value == this.value) {
            if (!nameList.contains(identityName)) this.nameList.add(identityName);
        }
    }

    public String getAbilityName() {
        return abilityName;
    }

    public Set<String> getNameList() {
        return nameList;
    }

    public String getAbNameWithNameList() {
        StringBuilder abNameWithNameList = new StringBuilder(abilityName).append(":");
        for (String name : nameList) {
            abNameWithNameList.append(name).append(",");
        }
        abNameWithNameList.deleteCharAt(abNameWithNameList.length() - 1);// 去掉最后的逗号
        return abNameWithNameList.toString();
    }

    public Double getValue() {
        return value;
    }

}
